<template>
  <div class="CX-view-box" ref="viewBox">
    <div class="seckill-component" id="seckill-component">
      <!--      <div class="app-header-nav">-->
      <!--&lt;!&ndash;        <el-image :src="nav" fit="cover"></el-image>&ndash;&gt;-->
      <!--      </div>-->
      <div class="app-content-box">
        <div class="head-box">


        </div>
        <div class="content-box">
          <div class="act-content">
            <div class="title-box"> 活动内容</div>
            <div class="content-info">
              {{ seckilData.activityContent | appData('activityContent') }}
            </div>
          </div>
        </div>
        <div class="products-content">
          <div class="title-box"> 适用产品</div>
          <div class="model-box">
            <el-row :gutter="10">
              <el-col :span="12" v-for="(item, index) in goodsList" :key="index">
                <div class="model-item">
                  <div class="model-img">
                    <el-image :src="getImgUrl(item.url)" fit="cover" style="height: 100%;width: 100%"></el-image>
                  </div>
                  <div class="model-info">
                    <div class="name">{{ item.modelInfo }}</div>
                    <div class="model-price">
                      <span class="now-price">¥
                        <span style="font-size: 15px;">{{ item.presentPrice }}</span>
                        {{ seckilData.bizType == 2 ? '/月' : '/天' }}</span>
                      <span class="old-price">¥{{ item.averagePrice }}{{ seckilData.bizType == 2 ? '/月' : '/天' }}</span>
                    </div>

                    <div class="model-number">
                      <el-row :gutter="10">
                        <el-col :span="9">
                          剩余{{ item.number || 0 }}
                        </el-col>
                        <el-col :span="11">
                          <button class="dingche">立即订车</button>
                        </el-col>
                      </el-row>
                    </div>
                  </div>
                </div>
              </el-col>
            </el-row>
          </div>
        </div>
        <div class="content-box">
          <div class="act-content">
            <div class="time">活动时间:{{ seckilData.startTime || '2022.06.30' }}-{{ seckilData.endTime || '2022.07.30' }}
            </div>
            <el-row :gutter="10">
              <el-col :span="10">
                <div class="store-info store-title">活动门店:</div>
              </el-col>
              <el-col :span="14">
                <div class="store-info store-name" v-for="(store, index) in activityUnit" :key="index">
                  <div>{{ store.applicableUnit }}</div>
                </div>
              </el-col>
            </el-row>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>


let defaultData = {
  activityName: "超值立减金限时大放送",
  activityContent: "活动内容文案活动内容文案活动内容文案活动内容文案活动内容文案活动内容文案活动内容文案活动内容文案活动内容文案活动内容文案活动内容文案活动内容"
}
export default {
  name: 'SeckillMobile',
  props: {
    seckilData: {
      activityName: {
        type: String,
        default() {
          return '0'
        },
      },
      activityContent: {
        type: String,
        default() {
          return '0'
        },
      },
      activityUnit: {
        type: Array,
        default() {
          return [{
            applicableUnit: "西安市高新科技园店",
            unitAddress: "西安市雁塔区GOGO街区"
          }]
        }
      }
    },
    goodsList: {
      type: Array,
      default() {
        return []
      },
    },
    activityUnit: {
      type: Array,
      default() {
        return []
      },
    },
  },
  filters: {
    appData(val, key) {
      if (val && val != '') {
        return val
      } else {
        return defaultData[key]
      }
    }
  },

  data() {
    return {
      carImage: require('./img/car.jpg'),
    }
  },
  mounted() {
    // js

    this.zoom()
    // 窗口大小变化时，需要重算
    window.addEventListener('resize', this.zoom, false)
  },
  methods: {
    zoom() {
      let domBody = document.getElementsByClassName('CX-view-box')[0]
      if (domBody?.style) {
        domBody.style.zoom = document.body.clientWidth / 22 + '%'
      }

    }
  },
  destroyed() {
    window.removeEventListener('resize', this.zoom, false)
  },
}
</script>

<style scoped>
.seckill-component {
  /* background: linear-gradient(to right, #eec5de, #ffecdb); */
  background: #0069ff;
  width: 374px;
  height: 735px;
  font-size: 12px;
  margin: 0 auto;

}

.right-box button {
  border-radius: 14px;
  color: #ffffff;
  font-size: 12px;
  background: linear-gradient(#eb222a 0%, #ff5266 100%);
  border: none;
  height: 28px;
  width: 90px;
}

.CX-view-box {
  background: #ffffff;
  width: 432px;
  height: 865px;
  font-size: 12px;
  margin: 0 auto;
  background-image: url(../commImg/phone/left.png), url(../commImg/phone/top.png), url(../commImg/phone/right.png), url(../commImg/phone/lower.png);
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
  background-position: left bottom, top, right bottom, bottom;
  padding: 65px 30px 59px 29px;
}

::-webkit-scrollbar {
  width: 0 !important;
}

::-webkit-scrollbar {
  width: 0 !important;
  height: 0;
}


.app-content-box {
  height: 100%;
  width: 100%;
  overflow: auto;
}

.content-box {
  width: 100%;
  /*background-image: url(img/yhq/yhqbg1.png);*/
  /*background-repeat: no-repeat;*/
  /*background-size: 100% 100%;*/
}

.title-box {
  background-image: url(img/titleBg.png);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  width: 171px;
  height: 41.5px;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  color: #ffffff;
  line-height: 32px;
  letter-spacing: 0.45px;
  text-shadow: 2px 5px 6px #0069ff;
  position: absolute;
  margin-top: -13px;
  left: 93px;
}

.act-content {
  background: #ffffff;
  border-radius: 15px;
  margin: 30px 9px;
  position: relative;
}

.content-info {
  height: 100%;
  padding: 42px 27px 27px 33px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: bold;
  text-align: left;
  color: #666666;
  line-height: 22.5px;
  letter-spacing: 0.28px;
  word-break: break-all;
}


.products-content {
  background: #ffffff;
  border-radius: 15px;
  margin: 0 9px;
  position: relative;
}

.model-box {
  width: 100%;
  padding: 38px 12px 2px 12px;
}

.model-item {
  width: 160.5px;
  height: 205.5px;
  background: #ffffff;
  border: 0.5px solid #bebebe;
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
}

.model-img {
  height: 85px;
}

.model-info .name {
  font-size: 14px;
  font-weight: bold;
  color: #131313;
  padding-top: 5px;
  letter-spacing: 0.35px;
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
  white-space: normal !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.model-number {
  font-size: 10px;
  font-weight: bold;
  text-align: left;
  color: #999999;
  letter-spacing: 0.25px;
  height: 25px;
  line-height: 26px;
}

.now-price {
  font-size: 11px;
  font-weight: bold;
  text-align: left;
  color: #ff781f;
}

.old-price {
  font-size: 12px;
  font-weight: bold;
  text-decoration: line-through;
  text-align: left;
  color: #aaaaaa;
  line-height: 32px;
}

.dingche {
  width: 90px;
  height: 28px;
  background: linear-gradient(#ff500b 0%, #ff9829 99%);
  border-radius: 14px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  color: #ffffff;
  line-height: 26px;
  letter-spacing: 0.36px;
}

.head-box {
  width: 100%;
  height: 320px;
  background-image: url(img/head.png);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}


.app-header-banner .app-header-card .app-header-card-price div {
  position: relative;
  display: inline-block;
  height: 20px;
}


p {
  margin: 0;
}


.content>>>img {
  width: 340px !important;
  margin: 0 auto;
}

.act-content .time {

  font-size: 14px;
  font-weight: bold;
  text-align: center;
  color: #666666;
  line-height: 32px;
  letter-spacing: 0.28px;
}

.store-info {
  font-size: 15px;
  font-weight: bold;
  color: #333333;
  line-height: 25px;
  letter-spacing: 0.3px;
}

.store-title {
  text-align: right;
}
</style>
